package common 
{
	import flash.utils.getQualifiedClassName;
	/**
	 * ...
	 * @author Luke Van In
	 */
	public class TestResult implements ITestResult 
	{
		
		private var _status:Boolean;
		
		private var _description:String;
		
		private var _message:String;
		
		
		
		/**
		 * 
		 * @param	status
		 * @param	message
		 */
		public function TestResult(status:Boolean, description:String, message:String) 
		{
			this._status = status;
			
			this._description = description;
			
			this._message = message;
		}
		
		
		
		/**
		 * 
		 * @return
		 */
		public function toString():String
		{
			var status:String = this._status ? "pass" : "fail";
			
			var s:String = this._description + " -> " + status + " " + this._message;
			
			return s;
		}
		
		
		
		/**
		 * 
		 * @return
		 */
		public function getStatus():Boolean 
		{
			return this._status;
		}
		
		
		
		/**
		 * 
		 * @return
		 */
		public function getDescription():String
		{
			return this._description;
		}
		
		
		/**
		 * 
		 * @return
		 */
		public function getMessage():String 
		{
			return this._message;
		}
		
		
		
		
		public static function create(test:ITest, status:Boolean, message:String):ITestResult
		{
			var description:String = getQualifiedClassName(test);
			
			var result:ITestResult = new TestResult(status, description, message);
			
			return result;
		}
		
		
		
		public static function fail(test:ITest, message:String):ITestResult
		{
			var result:ITestResult = TestResult.create(test, false, message);
			
			return result;
		}
		
		
		public static function success(test:ITest, message:String = ""):ITestResult
		{
			var result:ITestResult = TestResult.create(test, true, message);
			
			return result;
		}
		
		
		
		
	}

}